package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

/**
 * 转换流：InputStreamReader和OutputStreamWriter,它们继承自Reader和Writer
 */
public class OSWDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("ows.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("全都怪我，不该沉默时沉默");
        osw.write("该勇敢时软弱");
        System.out.println("写出完毕");
        osw.close();//关闭高级流时会自动关闭低级流
    }

}
